home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / Thread Manager / Sample Applications / 68k Examples / Traffic Threads / TrafficLight.r < prev    next >
Encoding:
Text File  |  1994-11-17  |  7.2 KB  |  353 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple Sample Application
  6. #
  7. #    Sample
  8. #
  9. #    Sample.r    -    Rez Source
  10. #
  11. #    Copyright © Apple Computer, Inc. 1989-1990
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #                1.00                08/88
  16. #                1.01                11/88
  17. #                1.02                04/89    MPW 3.1
  18. #                1.03                02/90    MPW 3.2
  19. #
  20. #    Components:
  21. #                Sample.c            Feb.  1, 1990
  22. #                Sample.r            Feb.  1, 1990
  23. #                Sample.h            Feb.  1, 1990
  24. #                Sample.make            Feb.  1, 1990
  25. #
  26. #    Sample is an example application that demonstrates how to
  27. #    initialize the commonly used toolbox managers, operate 
  28. #    successfully under MultiFinder, handle desk accessories, 
  29. #    and create, grow, and zoom windows.
  30. #
  31. #    It does not by any means demonstrate all the techniques 
  32. #    you need for a large application. In particular, Sample 
  33. #    does not cover exception handling, multiple windows/documents, 
  34. #    sophisticated memory management, printing, or undo. All of 
  35. #    these are vital parts of a normal full-sized application.
  36. #
  37. #    This application is an example of the form of a Macintosh 
  38. #    application; it is NOT a template. It is NOT intended to be 
  39. #    used as a foundation for the next world-class, best-selling, 
  40. #    600K application. A stick figure drawing of the human body may 
  41. #    be a good example of the form for a painting, but that does not 
  42. #    mean it should be used as the basis for the next Mona Lisa.
  43. #
  44. #    We recommend that you review this program or TESample before 
  45. #    beginning a new application.
  46. ------------------------------------------------------------------------------*/
  47.  
  48.  
  49. #include "SysTypes.r"
  50. #include "Types.r"
  51.  
  52. #define FOR_REZ 1 
  53. #include "TrafficLight.h"
  54.  
  55. resource 'vers' (1) {
  56.     0x01, 0x00, release, 0x00,
  57.     verUS,
  58.     "1.00",
  59.     "1.00, Copyright \251 Apple Computer, Inc. 1991"
  60. };
  61.  
  62.  
  63. /* this is a definition for a resource which contains only a rectangle */
  64.  
  65. type 'RECT' {
  66.     rect;
  67. };
  68.  
  69.  
  70. /* we use an MBAR resource to conveniently load all the menus */
  71.  
  72. resource 'MBAR' (rMenuBar, preload) {
  73.     { mApple, mFile, mEdit };    /* four menus */
  74. };
  75.  
  76.  
  77. resource 'MENU' (mApple, preload) {
  78.     mApple, textMenuProc,
  79.     AllItems & ~MenuItem2,    /* Disable dashed line, enable About and DAs */
  80.     enabled, apple,
  81.     {
  82.         "About Sample…",
  83.             noicon, nokey, nomark, plain;
  84.         "-",
  85.             noicon, nokey, nomark, plain
  86.     }
  87. };
  88.  
  89. resource 'MENU' (mFile, preload) {
  90.     mFile, textMenuProc,
  91.     MenuItem12,                /* enable Quit only, program enables others */
  92.     enabled, "File",
  93.     {
  94.         "New",
  95.             noicon, "N", nomark, plain;
  96.         "Open",
  97.             noicon, "O", nomark, plain;
  98.         "-",
  99.             noicon, nokey, nomark, plain;
  100.         "Close",
  101.             noicon, "W", nomark, plain;
  102.         "Save",
  103.             noicon, "S", nomark, plain;
  104.         "Save As…",
  105.             noicon, nokey, nomark, plain;
  106.         "Revert",
  107.             noicon, nokey, nomark, plain;
  108.         "-",
  109.             noicon, nokey, nomark, plain;
  110.         "Page Setup…",
  111.             noicon, nokey, nomark, plain;
  112.         "Print…",
  113.             noicon, nokey, nomark, plain;
  114.         "-",
  115.             noicon, nokey, nomark, plain;
  116.         "Quit",
  117.             noicon, "Q", nomark, plain
  118.     }
  119. };
  120.  
  121. resource 'MENU' (mEdit, preload) {
  122.     mEdit, textMenuProc,
  123.     NoItems,                /* disable everything, program does the enabling */
  124.     enabled, "Edit",
  125.      {
  126.         "Undo",
  127.             noicon, "Z", nomark, plain;
  128.         "-",
  129.             noicon, nokey, nomark, plain;
  130.         "Cut",
  131.             noicon, "X", nomark, plain;
  132.         "Copy",
  133.             noicon, "C", nomark, plain;
  134.         "Paste",
  135.             noicon, "V", nomark, plain;
  136.         "Clear",
  137.             noicon, nokey, nomark, plain
  138.     }
  139. };
  140.  
  141.  
  142. /* this ALRT and DITL are used as an About screen */
  143.  
  144. resource 'ALRT' (rAboutAlert, purgeable) {
  145.     {40, 20, 160, 297},
  146.     rAboutAlert,
  147.     { /* array: 4 elements */
  148.         /* [1] */
  149.         OK, visible, silent,
  150.         /* [2] */
  151.         OK, visible, silent,
  152.         /* [3] */
  153.         OK, visible, silent,
  154.         /* [4] */
  155.         OK, visible, silent
  156.     },
  157.     alertPositionMainScreen
  158. };
  159.  
  160. resource 'DITL' (rAboutAlert, purgeable) {
  161.     { /* array DITLarray: 5 elements */
  162.         /* [1] */
  163.         {88, 185, 108, 265},
  164.         Button {
  165.             enabled,
  166.             "OK"
  167.         },
  168.         /* [2] */
  169.         {8, 8, 24, 214},
  170.         StaticText {
  171.             disabled,
  172.             "Simple Sample (Traffic Light)"
  173.         },
  174.         /* [3] */
  175.         {32, 8, 48, 296},
  176.         StaticText {
  177.             disabled,
  178.             "Copyright © Apple Computer 1989-1990"
  179.         },
  180.         /* [4] */
  181.         {56, 8, 72, 136},
  182.         StaticText {
  183.             disabled,
  184.             "Brought to you by:"
  185.         },
  186.         /* [5] */
  187.         {80, 24, 112, 167},
  188.         StaticText {
  189.             disabled,
  190.             "Macintosh Developer  Technical Support"
  191.         }
  192.     }
  193. };
  194.  
  195.  
  196. /* this ALRT and DITL are used as an error screen */
  197.  
  198. resource 'ALRT' (rUserAlert, purgeable) {
  199.     {40, 20, 120, 260},
  200.     rUserAlert,
  201.     { /* array: 4 elements */
  202.         /* [1] */
  203.         OK, visible, silent,
  204.         /* [2] */
  205.         OK, visible, silent,
  206.         /* [3] */
  207.         OK, visible, silent,
  208.         /* [4] */
  209.         OK, visible, silent
  210.     },
  211.     alertPositionMainScreen
  212. };
  213.  
  214. /* this ALRT and DITL are used as an error screen */
  215.  
  216. resource 'ALRT' (rUserAlertContinue, purgeable) {
  217.     {40, 20, 150, 260},
  218.     rUserAlert,
  219.     { /* array: 4 elements */
  220.         /* [1] */
  221.         OK, visible, silent,
  222.         /* [2] */
  223.         OK, visible, silent,
  224.         /* [3] */
  225.         OK, visible, silent,
  226.         /* [4] */
  227.         OK, visible, silent
  228.     },
  229.     alertPositionMainScreen
  230. };
  231.  
  232.  
  233. resource 'DITL' (rUserAlertContinue, purgeable) {
  234.     { /* array DITLarray: 3 elements */
  235.         /* [1] */
  236.         {80, 150, 100, 230},
  237.         Button {
  238.             enabled,
  239.             "OK"
  240.         },
  241.         /* [2] */
  242.         {10, 60, 60, 230},
  243.         StaticText {
  244.             disabled,
  245.             "Error.  ^0."
  246.         },
  247.         /* [3] */
  248.         {8, 8, 40, 40},
  249.         Icon {
  250.             disabled,
  251.             2
  252.         }
  253.     }
  254. };
  255.  
  256. resource 'STR#' (kErrStrings, purgeable) {
  257.     {
  258.     "Command failed";
  259.     }
  260. };
  261.  
  262. resource 'DITL' (rUserAlert, purgeable) {
  263.     { /* array DITLarray: 3 elements */
  264.         /* [1] */
  265.         {50, 150, 70, 230},
  266.         Button {
  267.             enabled,
  268.             "OK"
  269.         },
  270.         /* [2] */
  271.         {10, 60, 30, 230},
  272.         StaticText {
  273.             disabled,
  274.             "Sample - Error occurred!"
  275.         },
  276.         /* [3] */
  277.         {8, 8, 40, 40},
  278.         Icon {
  279.             disabled,
  280.             2
  281.         }
  282.     }
  283. };
  284.  
  285. resource 'DLOG' (kDhrystoneDLOG, purgeable) {
  286.     {263, 29, 325, 450},
  287.     noGrowDocProc,
  288.     visible,
  289.     noGoAway,
  290.     0x0,
  291.     kDhrystoneDLOG,
  292.     "Dhrystone Thread",
  293.     centerMainScreen
  294. };
  295.  
  296. resource 'DITL' (kDhrystoneDLOG, purgeable) {
  297.     {    /* array DITLarray: 2 elements */
  298.         /* kMessageItem == [1] */
  299.         {18, 62, 43, 415},
  300.         StaticText {
  301.             disabled,
  302.             "Dhrystone started…"
  303.         },
  304.         /* [2] */
  305.         {10, 25, 42, 57},
  306.         Icon {
  307.             disabled,
  308.             1
  309.         }
  310.     }
  311. };
  312.  
  313.  
  314. resource 'STR#' (kDhrystoneString, purgeable) {{ "Dhrystone run #^0:  ^1 Dhrystones/Sec" }}; // µ
  315.  
  316. resource 'WIND' (rWindow, preload, purgeable) {
  317.     {60, 40, 290, 160},
  318.     noGrowDocProc, visible, goAway, 0x0, "Traffic", staggerMainScreen
  319. };
  320.  
  321. resource 'RECT' (rStopRect, preload, purgeable) {
  322.     {10, 10, 110, 110}
  323. };
  324.  
  325. resource 'RECT' (rGoRect, preload, purgeable) {
  326.     {120, 10, 220, 110}
  327. };
  328.  
  329.  
  330. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  331.  
  332. resource 'SIZE' (-1) {
  333.     dontSaveScreen,
  334.     acceptSuspendResumeEvents,
  335.     enableOptionSwitch,
  336.     canBackground,                /* we can background; we don't currently, but our sleep value */
  337.                                 /* guarantees we don't hog the Mac while we are in the background */
  338.     multiFinderAware,            /* this says we do our own activate/deactivate; don't fake us out */
  339.     backgroundAndForeground,    /* this is definitely not a background-only application! */
  340.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  341.     ignoreChildDiedEvents,        /* essentially, I'm not a debugger (sub-launching) */
  342.     not32BitCompatible,            /* this app should not be run in 32-bit address space */
  343.     reserved,
  344.     reserved,
  345.     reserved,
  346.     reserved,
  347.     reserved,
  348.     reserved,
  349.     reserved,
  350.     kPrefSize * 1024,
  351.     kMinSize * 1024    
  352. };
  353.